#/usr/localbin/python3
import os
def get_name():
    '用于获取文件名'
    while 1:
        fname = input('请输入文件名：')
        if not os.path.exists(fname):
            break
        print('文件已存在，请重输')
    return fname
def get_content():
    '用于获取内容'
    content = []
    while 1:
        line = input('请输入内容，以end结束：')
        if line == 'end':
            break
        content.append(line + '\n')
    return content

def write_file(fname, content):
    '写文件'
    with open(fname, 'w') as fobj:
        fobj.writelines(content)

if __name__ == '__main__':
    fname    = get_name()
    content = get_content()
    wfile    = write_file(fname, content)
